package com.baijiaoxi.common.model.base;

import com.baijiaoxi.common.constant.DateTime;
import lombok.Data;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Date;

@Data
public class DateStr {
    private String dayStr;
    private String monthStr;
    private String yearStr;
    private Date date;
    private String weekStr;
    public DateStr() {
    }

    public DateStr(Date date) {
        String dateStr = DateTime.SHORT_DATE.format(date);
        this.dayStr = dateStr;
        this.monthStr = dateStr.substring(0, 7);
        this.yearStr = dateStr.substring(0, 4);
        LocalDate localDate= LocalDate.parse(dayStr, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        LocalDate monday = localDate.with(DayOfWeek.MONDAY);
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        this.weekStr = df.format(monday);
    }
}
